//
//  HJZUploadViewController.m
//  HJZWeiBo
//
//  Created by 蒋晨成 on 16/6/4.
//  Copyright © 2016年 蒋晨成. All rights reserved.
//

#import "HJZUploadViewController.h"
#import "HJZKeyBoardToolBar.h"
#import "PhotosCollectionViewCell.h"
#import "ZYQAssetPickerController.h"
#import "UIImage+Extend.h"
#import <UIImageView+WebCache.h>
#import <AFNetworking.h>
#import "ContactViewController.h"
@interface HJZUploadViewController ()<UITextViewDelegate, UICollectionViewDelegate, UICollectionViewDataSource, UIImagePickerControllerDelegate, ZYQAssetPickerControllerDelegate, UINavigationControllerDelegate, ContactDelegate>

@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) UIButton *sendBtn;
@property (nonatomic, strong) HJZKeyBoardToolBar *toolBar;
@property (nonatomic, strong) UILabel *placeholderLabel;
@property (nonatomic, strong) UICollectionView *collectionView;
@property (nonatomic, strong) NSMutableArray *pics;
@property (nonatomic, strong) UIButton *shareButton;
@property (nonatomic, assign) BOOL isRetween;
@property (nonatomic, strong) UIView *statusView;
@property (nonatomic, assign) BOOL isFull;


@end

@implementation HJZUploadViewController


- (void)commentWithStatusID:(NSString *)statusID {
    AFHTTPSessionManager *mgr = [AFHTTPSessionManager manager];
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    params[@"access_token"] = [[NSUserDefaults standardUserDefaults] objectForKey:@"accessToken"];
    params[@"comment"] = self.textView.text;
    params[@"id"] = statusID;
    [mgr POST:@"https://api.weibo.com/2/comments/create.json" parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
        // 打印下上传进度
        self.sendBtn.enabled = NO;
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [self pushAlertViewWithText:@"发送成功"];
        });
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [self pushAlertViewWithText:@"发送成功"];
        });
    }];


}

- (void)retweenWithStatusID:(NSString *)statusID {
    AFHTTPSessionManager *mgr = [AFHTTPSessionManager manager];
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    params[@"access_token"] = [[NSUserDefaults standardUserDefaults] objectForKey:@"accessToken"];
    params[@"status"] = self.textView.text;
    params[@"id"] = statusID;
    [mgr POST:@"https://api.weibo.com/2/statuses/repost.json" parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
        // 打印下上传进度
        self.sendBtn.enabled = NO;
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [self pushAlertViewWithText:@"发送成功"];
        });
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [self pushAlertViewWithText:@"发送成功"];
        });
    }];
}

- (void)sendWithoutImage {
    AFHTTPSessionManager *mgr = [AFHTTPSessionManager manager];
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    params[@"access_token"] = [[NSUserDefaults standardUserDefaults] objectForKey:@"accessToken"];
    params[@"status"] = self.textView.text;
    [mgr POST:@"https://api.weibo.com/2/statuses/update.json" parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
        // 打印下上传进度
        self.sendBtn.enabled = NO;
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        dispatch_async(dispatch_get_main_queue(), ^{
              [self pushAlertViewWithText:@"发送成功"];
        });
       
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [self pushAlertViewWithText:@"发送成功"];
        });
    }];
    
}
- (void)sendWithImage {
    
    
    
    AFHTTPSessionManager *mgr = [AFHTTPSessionManager manager];

    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    params[@"access_token"] = [[NSUserDefaults standardUserDefaults] objectForKey:@"accessToken"];
    params[@"status"] = self.textView.text;
    
    
    
   [mgr POST:@"https://upload.api.weibo.com/2/statuses/upload.json" parameters:params constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
       NSInteger count = 0;
       if(_isFull) {
           count = _pics.count - 1;
       }else {
           count =  _pics.count - 2;
       }
       for (int i = 0; i <= count; i++) {
           NSData *data = nil;
          if (UIImagePNGRepresentation(_pics[i])) {
              data = UIImagePNGRepresentation(_pics[i]);
          }else {
              data = UIImageJPEGRepresentation(_pics[i], 1.0);
          }
       
        NSString *fileName = [NSString stringWithFormat:@"hjz%d.png",i];
        [formData appendPartWithFileData:data name:@"pic" fileName:fileName mimeType:@"image/png"];
       
       }
       
       
      
       
       
   } progress:^(NSProgress * _Nonnull uploadProgress) {
       // 打印下上传进度
       self.sendBtn.enabled = NO;
    

   } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
       dispatch_async(dispatch_get_main_queue(), ^{
           [self pushAlertViewWithText:@"发送成功"];
       });
   } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
       dispatch_async(dispatch_get_main_queue(), ^{
           [self pushAlertViewWithText:@"发送失败"];
       });
   }];

    
}




- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    [self registerForKeyboardNotifications];
    
    
    
    
    
    
    [self setupNavgationBar];
    [self setupTextView];
    [self setupCollectionView];
    if (_uploadType != UploadTypeStatus) {
        [self setupShareButton];
    }
    if (_uploadType == UploadTypeRetween) {
        [self setupStatusView];
    }
    [self setupToolBar];
    
    
    
  
    
   
    
    
    
}





/**
 *  设置工具条
 */
- (void)setupToolBar {
    self.toolBar = [[HJZKeyBoardToolBar alloc] initWithFrame:CGRectMake(0, kHeight - 64 - 50 - 258, kWidth, 50)];
    // 点击图片按钮
    __block HJZUploadViewController *blockSelf = self;
    self.toolBar.picButtonBlock = ^{
        [blockSelf openCameraOrAlbum];
    };
    // 点击艾特按钮
    self.toolBar.aiterButtonBlock = ^{
        ContactViewController *vc = [[ContactViewController alloc]init];
        vc.c_delegate = blockSelf;
        [blockSelf.navigationController pushViewController:vc animated:YES];
    };
    [self.view addSubview:_toolBar];
}

- (void)sendName:(NSString *)string {
    self.placeholderLabel.text = @"";
    self.textView.text = [NSString stringWithFormat:@"@%@%@",string,_textView.text];
}

/**
 * 设置输入框
 */
- (void)setupTextView {
    self.textView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, kWidth, 100)];
   
    if (_status.retweeted_status && _uploadType == UploadTypeRetween) {
        self.textView.text = [NSString stringWithFormat:@"//@%@:%@", _status.user.name, _status.text];
        NSRange range;
        range.location = 0;
        range.length = 0;
        self.textView.selectedRange = range;
    }
    [self.textView becomeFirstResponder];
    self.textView.delegate = self;
    [self.view addSubview:_textView];
    
    
    self.placeholderLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 200, 30)];
    self.placeholderLabel.enabled = NO;
    self.placeholderLabel.backgroundColor = [UIColor clearColor];
    if (_uploadType == UploadTypeComment) {
        self.placeholderLabel.text = @"写评论...";
    }else if (_uploadType == UploadTypeRetween) {
        if (_status.retweeted_status) {
            self.placeholderLabel.text = @"";
        }else {
            self.placeholderLabel.text = @"说说你分享心得...";
        }
    }else if (_uploadType == UploadTypeStatus) {
        self.placeholderLabel.text = @"分享新鲜事...";
    }
    [self.textView addSubview:_placeholderLabel];
}

/**
 * 设置导航栏
 */

- (void)setupNavgationBar {
    self.navigationController.navigationBar.translucent = NO;
    
    if (_uploadType == UploadTypeComment) {
        self.navigationItem.title = @"发评论";
    }else if (_uploadType == UploadTypeRetween) {
        self.navigationItem.title = @"转发微博";
    }else {
        self.navigationItem.title = @"发微博";
    }
    
    self.navigationController.navigationBar.tintColor = [UIColor blackColor];
    UIBarButtonItem *cancelBarButton = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:UIBarButtonItemStylePlain target:self action:@selector(cancelButtonAction:)];
    self.navigationItem.leftBarButtonItem=  cancelBarButton;
    
    self.sendBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.sendBtn setTitle:@"发送" forState:UIControlStateNormal];
    [self.sendBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    self.sendBtn.backgroundColor = [UIColor whiteColor];
    self.sendBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    self.sendBtn.frame = CGRectMake(0, 0, 50, 20);
    self.sendBtn.layer.borderColor = [UIColor grayColor].CGColor;
    self.sendBtn.layer.borderWidth = 0.5;
    self.sendBtn.layer.cornerRadius = 5;
    self.sendBtn.layer.masksToBounds = YES;
    self.sendBtn.enabled = YES;
    [self.sendBtn addTarget:self action:@selector(sendButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *sendBarButton = [[UIBarButtonItem alloc] initWithCustomView:_sendBtn];
    self.navigationItem.rightBarButtonItem = sendBarButton;

}

/**
 *  取消按钮
 */
- (void)cancelButtonAction:(UIBarButtonItem *)barButton {
    [self.textView resignFirstResponder];
    [self.navigationController dismissViewControllerAnimated:YES completion:nil];
}

/**
 *  发送按钮
 */
- (void)sendButtonAction:(UIButton *)button {
    
    
    if (_uploadType == UploadTypeStatus) {
        if (_pics.count == 0) {
             [self sendWithoutImage];
        }else {
            [self sendWithImage];
        }
    }else if (_uploadType == UploadTypeComment ) {
        [self commentWithStatusID:_status.idstr];
    }else if (_uploadType == UploadTypeRetween) {
        [self retweenWithStatusID:_status.idstr];
    }
   
    
}



/**
 *  同时转发评论按钮
 */
- (void)setupShareButton {
    self.shareButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.shareButton.frame = CGRectMake(0, kHeight - 64 - 50 - 258 - 20, 100, 20);
    self.shareButton.titleLabel.font = [UIFont systemFontOfSize:13];
    [self.shareButton setImage:[UIImage resizedImageWithName:@"new_feature_share_false"] forState:UIControlStateNormal];
    [self.shareButton setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
    if (_uploadType == UploadTypeComment) {
         [self.shareButton setTitle:@"同时转发" forState:UIControlStateNormal];
    }else {
         [self.shareButton setTitle:@"同时评论" forState:UIControlStateNormal];
    }
   
    self.shareButton.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);
    self.shareButton.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 5);
    
    [self.view addSubview:_shareButton];
    [self.shareButton addTarget:self action:@selector(shareButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)shareButtonAction:(UIButton *)button {
    self.isRetween = !_isRetween;
    if (self.isRetween) {
        [button setImage:[UIImage resizedImageWithName:@"new_feature_share_true"] forState:UIControlStateNormal];
    }else {
        [button setImage:[UIImage resizedImageWithName:@"new_feature_share_false"] forState:UIControlStateNormal];
    }
}


/**
 *  当输入框内容发生改变
 */
- (void)textViewDidChange:(UITextView *)textView {
    if (textView.contentSize.height >= 100 && textView.contentSize.height <= 200 ) {
        CGRect frame = textView.frame;
        frame.size.height = textView.contentSize.height;
        textView.frame = frame;
        CGRect collectionViewFrame = _collectionView.frame;
        collectionViewFrame.origin.y = frame.size.height;
        self.collectionView.frame = collectionViewFrame;
        
        CGRect statusFrame = _statusView.frame;
        if (_pics.count == 0) {
            statusFrame.origin.y = frame.size.height;
        }else {
            statusFrame.origin.y = CGRectGetMaxY(collectionViewFrame);
        }
        self.statusView.frame = statusFrame;
        
    }
    
    
    if (textView.text.length > 0) {
        [self.sendBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        self.sendBtn.backgroundColor = [UIColor orangeColor];
        self.sendBtn.enabled = YES;
        self.placeholderLabel.text = @"";
        
    }else {
        
        if (_uploadType == UploadTypeComment) {
            self.placeholderLabel.text = @"写评论...";
        }else if (_uploadType == UploadTypeRetween) {
            self.placeholderLabel.text = @"说说你分享心得...";
        }else if (_uploadType == UploadTypeStatus) {
            self.placeholderLabel.text = @"分享新鲜事...";
        }
        [self.sendBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
        self.sendBtn.backgroundColor = [UIColor whiteColor];
        self.sendBtn.enabled = NO;
    }
}


- (void)registerForKeyboardNotifications
{
    //使用NSNotificationCenter 鍵盤出現時
    [[NSNotificationCenter defaultCenter] addObserver:self
     
                                             selector:@selector(keyboardWasShown:)
     
                                                 name:UIKeyboardDidShowNotification object:nil];
    
    //使用NSNotificationCenter 鍵盤隐藏時
    [[NSNotificationCenter defaultCenter] addObserver:self
     
                                             selector:@selector(keyboardWillBeHidden:)
     
                                                 name:UIKeyboardWillHideNotification object:nil];
    
    
}

//实现当键盘出现的时候计算键盘的高度大小。用于输入框显示位置
- (void)keyboardWasShown:(NSNotification*)aNotification
{
    NSDictionary* info = [aNotification userInfo];
    //kbSize即為鍵盤尺寸 (有width, height)
    CGSize kbSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;//得到鍵盤的高度


    [UIView animateWithDuration:0.1 animations:^{
        self.toolBar.frame = CGRectMake(0, kHeight - 64 - kbSize.height - 50, kWidth, 50);
        self.shareButton.frame = CGRectMake(0, kHeight - 64 - kbSize.height - 50 - 20, 100, 20);
        
    }];
    
  
    
    
    
    
}



//当键盘隐藏的时候
- (void)keyboardWillBeHidden:(NSNotification*)aNotification
{
    //do something
    [UIView animateWithDuration:0.1 animations:^{
        self.toolBar.frame = CGRectMake(0, kHeight - 64 - 50, kWidth, 50);
        self.shareButton.frame = CGRectMake(0, kHeight - 64 - 50 - 20, 100, 20);
    }];
   
}


/**
 * 设置collectionView
 */

- (void)setupCollectionView {
    
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    flowLayout.itemSize = CGSizeMake((kWidth - 40) / 3.0 , (kWidth - 40) / 3.0);
    flowLayout.minimumInteritemSpacing = 10;
    flowLayout.minimumLineSpacing = 10;
    flowLayout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);

    
    self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 100, kWidth, kWidth) collectionViewLayout:flowLayout];
    if (_uploadType != UploadTypeStatus) {
        self.collectionView.frame = CGRectMake(10, 100, (kWidth - 40) / 3.0, (kWidth - 40) / 3.0);
    }
    self.collectionView.backgroundColor = [UIColor clearColor];
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    [self.view addSubview:_collectionView];
    [self.collectionView registerClass:[PhotosCollectionViewCell class] forCellWithReuseIdentifier:@"PhotosCollectionViewCell"];
    
}


- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    if (_pics.count == 0) {
        [self reloadStatusView];
    }
    return _pics.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    PhotosCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"PhotosCollectionViewCell" forIndexPath:indexPath];
    cell.photo.image = _pics[indexPath.row];

    
   
    return cell;
}


- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    if (!self.isFull && indexPath.row == _pics.count -1 && _uploadType == UploadTypeStatus) {
        [self openCameraOrAlbum];
    }else {
      
        [self.pics removeObjectAtIndex:indexPath.row];
        [_collectionView deleteItemsAtIndexPaths:@[indexPath]];
        if (self.isFull) {
            [self.pics addObject:[UIImage imageNamed:@"plus.png"]];
            [_collectionView reloadData];
            self.isFull = NO;
        }
        
        
        if (_uploadType == UploadTypeStatus) {
            if (self.pics.count == 1) {
                [self.pics removeObjectAtIndex:0];
                [_collectionView deleteItemsAtIndexPaths:@[[NSIndexPath indexPathForItem:0 inSection:0]]];
            }
        }
        }
    
}



/**
 *  警告框
 */
- (void)pushAlertViewWithText:(NSString *)text {
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:text message:nil preferredStyle:UIAlertControllerStyleAlert];
    [self.navigationController presentViewController:alert animated:YES completion:^{
        [self performSelector:@selector(delayPop:) withObject:alert afterDelay:1];
    }];
}
- (void)delayPop:(UIAlertController *)alert {
    [self.navigationController dismissViewControllerAnimated:YES completion:^{
        [self.navigationController dismissViewControllerAnimated:YES completion:nil];
    }];
}

/**
 *   打开相册相机
 */

- (void)openCameraOrAlbum {
    [self resignFirstResponder];
   
    
   
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
        ZYQAssetPickerController *picker = [[ZYQAssetPickerController alloc] init];
        NSInteger flag = 1;
        if(_uploadType == UploadTypeStatus) {
            flag = 9;
        }
        picker.maximumNumberOfSelection = flag;
        picker.assetsFilter = [ALAssetsFilter allPhotos];
        picker.showEmptyGroups=NO;
        picker.delegate = self;
        picker.selectionFilter = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) {
            if ([[(ALAsset*)evaluatedObject valueForProperty:ALAssetPropertyType] isEqual:ALAssetTypeVideo]) {
                NSTimeInterval duration = [[(ALAsset*)evaluatedObject valueForProperty:ALAssetPropertyDuration] doubleValue];
                return duration >= 5;
            } else {
                return YES;
            }
        }];
        
        [self presentViewController:picker animated:YES completion:NULL];
       
    }
    
}
- (void)assetPickerController:(ZYQAssetPickerController *)picker didFinishPickingAssets:(NSArray *)assets{
    if (!self.pics) {
        self.pics = [NSMutableArray array];
    }
    if (_uploadType != UploadTypeStatus) {
        [self.pics removeAllObjects];
    }else {
        [self.pics removeLastObject];
    }
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSInteger flag = 1;
        if (_uploadType == UploadTypeStatus) {
            flag = 9;
        }
        for (int i = 0; i<assets.count; i++) {
            ALAsset *asset=assets[i];
            UIImage *tempImg=[UIImage imageWithCGImage:asset.defaultRepresentation.fullScreenImage];
           
            if (_pics.count == flag) {
                dispatch_async(dispatch_get_main_queue(), ^{
                    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"图片超过上限" message:nil preferredStyle:UIAlertControllerStyleAlert];
                    [self.navigationController presentViewController:alert animated:YES completion:^{
                        [self performSelector:@selector(dismissAlert:) withObject:alert afterDelay:1];
                    }];
                });
                break;
            }
            [self.pics addObject:tempImg];
        }
        if (_uploadType == UploadTypeStatus) {
            if (self.pics.count != 9) {
                [self.pics addObject:[UIImage imageNamed:@"plus.png"]];
            }else {
                self.isFull = YES;
            }
        }
        
        dispatch_async(dispatch_get_main_queue(), ^{
            [self.collectionView reloadData];
            if (_pics.count == 0) {
                self.statusView.frame = CGRectMake(10, _textView.frame.size.height, kWidth - 20, 50);
            }else {
                self.statusView.frame = CGRectMake(10, CGRectGetMaxY(_collectionView.frame), kWidth - 20, 50);
            }
        });
    });
    
   
    
}

- (void)dismissAlert:(UIAlertController *)alertVC {
    [self.navigationController dismissViewControllerAnimated:YES completion:nil];
}



/**
 *  转发微博内容
 */

- (void)setupStatusView {
    self.statusView = [[UIView alloc] initWithFrame:CGRectMake(10, 100, kWidth - 20, 50)];
    self.statusView.backgroundColor = PKCOLOR(230, 230, 230);
    [self.view addSubview:_statusView];
    UIImageView *iconImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
    [self.statusView addSubview:iconImageView];
    
    UILabel *userLabel = [[UILabel alloc] initWithFrame:CGRectMake(60, 10, kWidth - 80, 20)];
    [self.statusView addSubview:userLabel];
    
    UILabel *contentLabel = [[UILabel alloc] initWithFrame:CGRectMake(60, 30, kWidth - 80, 20)];
    contentLabel.numberOfLines = 2;
    contentLabel.font = [UIFont systemFontOfSize:10];
    contentLabel.textColor = [UIColor grayColor];
    [self.statusView addSubview:contentLabel];
    
    if (_status.retweeted_status) {
        [iconImageView sd_setImageWithURL:[NSURL URLWithString:_status.retweeted_status.user.profile_image_url]];
        userLabel.text = [NSString stringWithFormat:@"@%@",_status.retweeted_status.user.name];
        contentLabel.text =_status.retweeted_status.text;
    }else {
        [iconImageView sd_setImageWithURL:[NSURL URLWithString:_status.user.profile_image_url]];
        userLabel.text = [NSString stringWithFormat:@"@%@",_status.user.name];
        contentLabel.text =_status.text;
        
    }
}
- (void)reloadStatusView {
    if (_uploadType == UploadTypeRetween) {
        self.statusView.frame = CGRectMake(10, 100, kWidth - 20, 50);

    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
